home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / CodeWarrior Lite / Metrowerks C⁄C++ Lite / Headers / Universal Headers 2.0.1f / TextServices.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-22  |  12.6 KB  |  329 lines  |  [TEXT/MMCC]

  1. /*
  2.      File:        TextServices.h
  3.  
  4.      Contains:    Text Services Manager Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. */
  19.  
  20. #ifndef __TEXTSERVICES__
  21. #define __TEXTSERVICES__
  22.  
  23.  
  24. #ifndef __TYPES__
  25. #include <Types.h>
  26. #endif
  27. /*    #include <ConditionalMacros.h>                                */
  28.  
  29. #ifndef __EVENTS__
  30. #include <Events.h>
  31. #endif
  32. /*    #include <Quickdraw.h>                                        */
  33. /*        #include <MixedMode.h>                                    */
  34. /*        #include <QuickdrawText.h>                                */
  35. /*    #include <OSUtils.h>                                        */
  36. /*        #include <Memory.h>                                        */
  37.  
  38. #ifndef __MENUS__
  39. #include <Menus.h>
  40. #endif
  41.  
  42. #ifndef __APPLEEVENTS__
  43. #include <AppleEvents.h>
  44. #endif
  45. /*    #include <Errors.h>                                            */
  46. /*    #include <EPPC.h>                                            */
  47. /*        #include <AppleTalk.h>                                    */
  48. /*        #include <Files.h>                                        */
  49. /*        #include <PPCToolbox.h>                                    */
  50. /*        #include <Processes.h>                                    */
  51. /*    #include <Notification.h>                                    */
  52.  
  53. #ifndef __ERRORS__
  54. #include <Errors.h>
  55. #endif
  56.  
  57. #ifndef __COMPONENTS__
  58. #include <Components.h>
  59. #endif
  60.  
  61. #ifdef __cplusplus
  62. extern "C" {
  63. #endif
  64.  
  65. #if PRAGMA_ALIGN_SUPPORTED
  66. #pragma options align=mac68k
  67. #endif
  68.  
  69. #if PRAGMA_IMPORT_SUPPORTED
  70. #pragma import on
  71. #endif
  72.  
  73.  
  74. enum {
  75.     kTSMVersion                    = 0x200,                        /* Version of the Text Services Manager is 2.0  */
  76.     kTextService                = 'tsvc',                        /* component type for the component description */
  77.     kInputMethodService            = 'inpm',                        /* component subtype for the component description */
  78. /* Component Flags in ComponentDescription */
  79.     bTakeActiveEvent            = 15,                            /* bit set if the component takes active event */
  80.     bHandleAERecording            = 16,                            /* bit set if the component takes care of recording Apple Events <new in vers2.0> */
  81.     bScriptMask                    = 0x00007F00,                    /* bit 8 - 14 */
  82.     bLanguageMask                = 0x000000FF,                    /* bit 0 - 7  */
  83.     bScriptLanguageMask            = bScriptMask + bLanguageMask    /* bit 0 - 14  */
  84. };
  85.  
  86. enum {
  87. /* Hilite styles */
  88.     kCaretPosition                = 1,                            /* specify caret position */
  89.     kRawText                    = 2,                            /* specify range of raw text */
  90.     kSelectedRawText            = 3,                            /* specify range of selected raw text */
  91.     kConvertedText                = 4,                            /* specify range of converted text */
  92.     kSelectedConvertedText        = 5                                /* specify range of selected converted text */
  93. };
  94.  
  95. /* Apple Event constants */
  96. enum {
  97. /* Event class */
  98.     kTextServiceClass            = kTextService,
  99. /* event ID */
  100.     kUpdateActiveInputArea        = 'updt',                        /* update the active Inline area */
  101.     kPos2Offset                    = 'p2st',                        /* converting global coordinates to char position */
  102.     kOffset2Pos                    = 'st2p',                        /* converting char position to global coordinates */
  103.     kShowHideInputWindow        = 'shiw',                        /* show or hide the input window */
  104. /* Event keywords */
  105.     keyAETSMDocumentRefcon        = 'refc',                        /* TSM document refcon, typeLongInteger */
  106. /* Note: keyAETSMScriptTag, keyAERequestedType, keyAETSMTextFont, keyAETextPointSize
  107.     typeAEText, typeIntlWritingCode, typeQDPoint, and keyAEAngle have been moved to 
  108.     AERegistry.h */
  109.     keyAEServerInstance            = 'srvi',                        /* component instance */
  110.     keyAETheData                = 'kdat',                        /* typeText */
  111.     keyAEFixLength                = 'fixl',                        /* fix len ?? */
  112.     keyAEHiliteRange            = 'hrng',                        /* hilite range array */
  113.     keyAEUpdateRange            = 'udng',                        /* update range array */
  114.     keyAEClauseOffsets            = 'clau',                        /* Clause Offsets array */
  115.     keyAECurrentPoint            = 'cpos',                        /* current point */
  116.     keyAEDragging                = 'bool',                        /* dragging falg */
  117.     keyAEOffset                    = 'ofst',                        /* offset */
  118.     keyAERegionClass            = 'rgnc',                        /* region class */
  119.     keyAEPoint                    = 'gpos',                        /* current point */
  120.     keyAEBufferSize                = 'buff',                        /* buffer size to get the text */
  121.     keyAEMoveView                = 'mvvw',                        /* move view flag */
  122.     keyAELength                    = 'leng',                        /* length */
  123.     keyAENextBody                = 'nxbd',                        /* next or previous body */
  124. /* optional keywords for Offset2Pos (Info about the active input area) */
  125.     keyAETextLineHeight            = 'ktlh',                        /* typeShortInteger */
  126.     keyAETextLineAscent            = 'ktas',                        /* typeShortInteger */
  127. /* optional keywords for Pos2Offset */
  128.     keyAELeftSide                = 'klef',                        /* type Boolean */
  129. /* optional keywords for kShowHideInputWindow */
  130.     keyAEShowHideInputWindow    = 'shiw',                        /* type Boolean */
  131. /* for PinRange  */
  132.     keyAEPinRange                = 'pnrg',
  133. /* Desc type ... */
  134.     typeComponentInstance        = 'cmpi',                        /* server instance */
  135.     typeTextRangeArray            = 'tray',                        /* text range array */
  136.     typeOffsetArray                = 'ofay',                        /* offset array */
  137.     typeText                    = typeChar,                        /* Plain text */
  138.     typeTextRange                = 'txrn'
  139. };
  140.  
  141. /* Desc type constants */
  142. enum {
  143.     kTSMOutsideOfBody            = 1,
  144.     kTSMInsideOfBody            = 2,
  145.     kTSMInsideOfActiveInputArea    = 3
  146. };
  147.  
  148. enum {
  149.     kNextBody                    = 1,
  150.     kPreviousBody                = 2
  151. };
  152.  
  153. /* typeTextRange         'txrn' */
  154. struct TextRange {
  155.     long                            fStart;
  156.     long                            fEnd;
  157.     short                            fHiliteStyle;
  158. };
  159. typedef struct TextRange TextRange;
  160.  
  161. typedef TextRange *TextRangePtr;
  162.  
  163. typedef TextRangePtr *TextRangeHandle;
  164.  
  165. /* typeTextRangeArray    'txra' */
  166. struct TextRangeArray {
  167.     short                            fNumOfRanges;                /* specify the size of the fRange array */
  168.     TextRange                        fRange[1];                    /* when fNumOfRanges > 1, the size of this array has to be calculated */
  169. };
  170. typedef struct TextRangeArray TextRangeArray;
  171.  
  172. typedef TextRangeArray *TextRangeArrayPtr;
  173.  
  174. typedef TextRangeArrayPtr *TextRangeArrayHandle;
  175.  
  176. /* typeOffsetArray        'offa' */
  177. struct OffsetArray {
  178.     short                            fNumOfOffsets;                /* specify the size of the fOffset array */
  179.     long                            fOffset[1];                    /* when fNumOfOffsets > 1, the size of this array has to be calculated */
  180. };
  181. typedef struct OffsetArray OffsetArray;
  182.  
  183. typedef OffsetArray *OffsetArrayPtr;
  184.  
  185. typedef OffsetArrayPtr *OffsetArrayHandle;
  186.  
  187. #define mGetScriptCode(cdRec) ((ScriptCode)    ((cdRec.componentFlags & bScriptMask) >> 8))
  188. #define mGetLanguageCode(cdRec) ((LangCode)    cdRec.componentFlags & bLanguageMask)
  189. typedef void *TSMDocumentID;
  190.  
  191. typedef OSType InterfaceTypeList[1];
  192.  
  193. /* Text Service Info List */
  194. struct TextServiceInfo {
  195.     Component                        fComponent;
  196.     Str255                            fItemName;
  197. };
  198. typedef struct TextServiceInfo TextServiceInfo;
  199.  
  200. typedef TextServiceInfo *TextServiceInfoPtr;
  201.  
  202. struct TextServiceList {
  203.     short                            fTextServiceCount;            /* number of entries in the 'fServices' array */
  204.     TextServiceInfo                    fServices[1];                /* Note: array of 'TextServiceInfo' records follows */
  205. };
  206. typedef struct TextServiceList TextServiceList;
  207.  
  208. typedef TextServiceList *TextServiceListPtr;
  209.  
  210. typedef TextServiceListPtr *TextServiceListHandle;
  211.  
  212. struct ScriptLanguageRecord {
  213.     ScriptCode                        fScript;
  214.     LangCode                        fLanguage;
  215. };
  216. typedef struct ScriptLanguageRecord ScriptLanguageRecord;
  217.  
  218. struct ScriptLanguageSupport {
  219.     short                            fScriptLanguageCount;        /* number of entries in the 'fScriptLanguageArray' array */
  220.     ScriptLanguageRecord            fScriptLanguageArray[1];    /* Note: array of 'ScriptLanguageRecord' records follows */
  221. };
  222. typedef struct ScriptLanguageSupport ScriptLanguageSupport;
  223.  
  224. typedef ScriptLanguageSupport *ScriptLanguageSupportPtr;
  225.  
  226. typedef ScriptLanguageSupportPtr *ScriptLanguageSupportHandle;
  227.  
  228.  
  229. enum {
  230. /* Low level routines which are dispatched directly to the Component Manager */
  231.     kCMGetScriptLangSupport        = 0x0001,                        /* Component Manager call selector 1 */
  232.     kCMInitiateTextService        = 0x0002,                        /* Component Manager call selector 2 */
  233.     kCMTerminateTextService        = 0x0003,                        /* Component Manager call selector 3 */
  234.     kCMActivateTextService        = 0x0004,                        /* Component Manager call selector 4 */
  235.     kCMDeactivateTextService    = 0x0005,                        /* Component Manager call selector 5 */
  236.     kCMTextServiceEvent            = 0x0006,                        /* Component Manager call selector 6 */
  237.     kCMGetTextServiceMenu        = 0x0007,                        /* Component Manager call selector 7 */
  238.     kCMTextServiceMenuSelect    = 0x0008,                        /* Component Manager call selector 8 */
  239.     kCMFixTextService            = 0x0009,                        /* Component Manager call selector 9 */
  240.     kCMSetTextServiceCursor        = 0x000A,                        /* Component Manager call selector 10 */
  241.     kCMHidePaletteWindows        = 0x000B                        /* Component Manager call selector 11 */
  242. };
  243.  
  244. /* High level TSM routines */
  245. extern pascal OSErr NewTSMDocument(short numOfInterface, InterfaceTypeList supportedInterfaceTypes, TSMDocumentID *idocID, long refcon)
  246.  TWOWORDINLINE(0x7000, 0xAA54);
  247. extern pascal OSErr DeleteTSMDocument(TSMDocumentID idocID)
  248.  TWOWORDINLINE(0x7001, 0xAA54);
  249. extern pascal OSErr ActivateTSMDocument(TSMDocumentID idocID)
  250.  TWOWORDINLINE(0x7002, 0xAA54);
  251. extern pascal OSErr DeactivateTSMDocument(TSMDocumentID idocID)
  252.  TWOWORDINLINE(0x7003, 0xAA54);
  253. extern pascal Boolean TSMEvent(EventRecord *event)
  254.  TWOWORDINLINE(0x7004, 0xAA54);
  255. extern pascal Boolean TSMMenuSelect(long menuResult)
  256.  TWOWORDINLINE(0x7005, 0xAA54);
  257. extern pascal Boolean SetTSMCursor(Point mousePos)
  258.  TWOWORDINLINE(0x7006, 0xAA54);
  259. extern pascal OSErr FixTSMDocument(TSMDocumentID idocID)
  260.  TWOWORDINLINE(0x7007, 0xAA54);
  261. extern pascal OSErr GetServiceList(short numOfInterface, OSType *supportedInterfaceTypes, TextServiceListHandle *serviceInfo, long *seedValue)
  262.  TWOWORDINLINE(0x7008, 0xAA54);
  263. extern pascal OSErr OpenTextService(TSMDocumentID idocID, Component aComponent, ComponentInstance *aComponentInstance)
  264.  TWOWORDINLINE(0x7009, 0xAA54);
  265. extern pascal OSErr CloseTextService(TSMDocumentID idocID, ComponentInstance aComponentInstance)
  266.  TWOWORDINLINE(0x700A, 0xAA54);
  267. extern pascal OSErr SendAEFromTSMComponent(const AppleEvent *theAppleEvent, AppleEvent *reply, AESendMode sendMode, AESendPriority sendPriority, long timeOutInTicks, AEIdleUPP idleProc, AEFilterUPP filterProc)
  268.  TWOWORDINLINE(0x700B, 0xAA54);
  269. extern pascal OSErr InitTSMAwareApplication(void)
  270.  TWOWORDINLINE(0x7014, 0xAA54);
  271. extern pascal OSErr CloseTSMAwareApplication(void)
  272.  TWOWORDINLINE(0x7015, 0xAA54);
  273. /* Utilities */
  274. extern pascal OSErr SetDefaultInputMethod(Component ts, ScriptLanguageRecord *slRecordPtr)
  275.  TWOWORDINLINE(0x700C, 0xAA54);
  276. extern pascal OSErr GetDefaultInputMethod(Component *ts, ScriptLanguageRecord *slRecordPtr)
  277.  TWOWORDINLINE(0x700D, 0xAA54);
  278. extern pascal OSErr SetTextServiceLanguage(ScriptLanguageRecord *slRecordPtr)
  279.  TWOWORDINLINE(0x700E, 0xAA54);
  280. extern pascal OSErr GetTextServiceLanguage(ScriptLanguageRecord *slRecordPtr)
  281.  TWOWORDINLINE(0x700F, 0xAA54);
  282. extern pascal OSErr UseInputWindow(TSMDocumentID idocID, Boolean useWindow)
  283.  TWOWORDINLINE(0x7010, 0xAA54);
  284. extern pascal OSErr NewServiceWindow(void *wStorage, const Rect *boundsRect, ConstStr255Param title, Boolean visible, short theProc, WindowPtr behind, Boolean goAwayFlag, ComponentInstance ts, WindowPtr *window)
  285.  TWOWORDINLINE(0x7011, 0xAA54);
  286. extern pascal OSErr CloseServiceWindow(WindowPtr window)
  287.  TWOWORDINLINE(0x7012, 0xAA54);
  288. extern pascal OSErr GetFrontServiceWindow(WindowPtr *window)
  289.  TWOWORDINLINE(0x7013, 0xAA54);
  290. extern pascal short FindServiceWindow(Point thePoint, WindowPtr *theWindow)
  291.  TWOWORDINLINE(0x7017, 0xAA54);
  292. /* Low level TSM routines */
  293. extern pascal ComponentResult GetScriptLanguageSupport(ComponentInstance ts, ScriptLanguageSupportHandle *scriptHdl)
  294.  FIVEWORDINLINE(0x2F3C, 0x04, 0x0001, 0x7000, 0xA82A);
  295. extern pascal ComponentResult InitiateTextService(ComponentInstance ts)
  296.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0002, 0x7000, 0xA82A);
  297. extern pascal ComponentResult TerminateTextService(ComponentInstance ts)
  298.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0003, 0x7000, 0xA82A);
  299. extern pascal ComponentResult ActivateTextService(ComponentInstance ts)
  300.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0004, 0x7000, 0xA82A);
  301. extern pascal ComponentResult DeactivateTextService(ComponentInstance ts)
  302.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0005, 0x7000, 0xA82A);
  303. extern pascal ComponentResult TextServiceEvent(ComponentInstance ts, short numOfEvents, EventRecord *event)
  304.  FIVEWORDINLINE(0x2F3C, 0x06, 0x0006, 0x7000, 0xA82A);
  305. extern pascal ComponentResult GetTextServiceMenu(ComponentInstance ts, MenuHandle *serviceMenu)
  306.  FIVEWORDINLINE(0x2F3C, 0x4, 0x0007, 0x7000, 0xA82A);
  307. extern pascal ComponentResult TextServiceMenuSelect(ComponentInstance ts, MenuHandle serviceMenu, short item)
  308.  FIVEWORDINLINE(0x2F3C, 0x06, 0x0008, 0x7000, 0xA82A);
  309. extern pascal ComponentResult FixTextService(ComponentInstance ts)
  310.  FIVEWORDINLINE(0x2F3C, 0x00, 0x0009, 0x7000, 0xA82A);
  311. extern pascal ComponentResult SetTextServiceCursor(ComponentInstance ts, Point mousePos)
  312.  FIVEWORDINLINE(0x2F3C, 0x04, 0x000A, 0x7000, 0xA82A);
  313. extern pascal ComponentResult HidePaletteWindows(ComponentInstance ts)
  314.  FIVEWORDINLINE(0x2F3C, 0x00, 0x000B, 0x7000, 0xA82A);
  315.  
  316. #if PRAGMA_IMPORT_SUPPORTED
  317. #pragma import off
  318. #endif
  319.  
  320. #if PRAGMA_ALIGN_SUPPORTED
  321. #pragma options align=reset
  322. #endif
  323.  
  324. #ifdef __cplusplus
  325. }
  326. #endif
  327.  
  328. #endif /* __TEXTSERVICES__ */
  329.